package cn.minhx.mw.acr.sdk;

import java.io.BufferedReader;
import java.io.File;
import java.io.InputStreamReader;

public class Stater {

    public static void main(String[] args) throws Exception {
        File curDir = new File(".");
        ProcessBuilder processBuilder = new ProcessBuilder("git", "diff", "HEAD~1", "HEAD").directory(curDir);
        Process process = processBuilder.start();

        // 获取命令输出
        BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));

        StringBuilder diff = new StringBuilder();
        String line;
        while ((line = reader.readLine()) != null) {
            diff.append(line);
        }

        // 等待进程结束
        int exitCode = process.waitFor();
        if (exitCode == 0) {
            // 正常退出
            System.out.println("Diff generated successfully.");
        }

        System.out.println("diff：" + diff);

        Reviewer reviewer = new Reviewer();
        String sug = reviewer.review(diff.toString());

        System.out.println("sug = " + sug);
    }

}